﻿#include "cmd_surface.h"
#include "algo/algo_approximate.h"
#include "algo/algo_interpolate.h"

CAGD::CmdStatus CAGD::CmdBSplineSurface::Perform()
{
    // 获取插值点， nu 个 u，每列 n 个点
    int nv = 5;
    int nu = m_points.size() / nv;
    std::vector<std::vector<BPnt>> tar(nu, std::vector<BPnt>(nv));
    for (int i = 0; i < nu; i++)
        for (int j = 0; j < nv; j++)
            tar[i][j] = m_points[i * nv + j]->GetPoint()->Point();

    // 获得构造曲面
    m_surface = Interpolate::BSplineSurface3x3(tar);
    return CmdSurfaceBuilder::Perform();
}